package com.example.towSpringBoot.mapper;


import com.example.towSpringBoot.dto.EmployeeDto;
import com.example.towSpringBoot.dto.EmployeePageQueryDto;
import com.example.towSpringBoot.dto.EmployeeRoleDto;
import com.example.towSpringBoot.dto.LoginDto;
import com.example.towSpringBoot.entity.Department;
import com.example.towSpringBoot.entity.Employee;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;


import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xinTong
 * @since 2024-01-23
 */
public interface EmployeeMapper{

    /**
     * 员工查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    //@Select("select * from rbac.employee limit #{pageNum},#{pageSize}")
    Page<EmployeeDto> list(EmployeePageQueryDto queryDto);

    /**
     * 删除员工
     * @param id
     */
    @Delete("delete from rbac.employee where id = #{id}")
    void delete(Long id);

    //@Select("select * from rbac.employee where id = #{id}")
    EmployeeDto info(Long id);

    /**
     * 更新员工
     * @param employeeDto
     */
    void update(Employee employee);

    /**
     * 新增员工
     *
     * @param employeeDto
     * @return
     */
    //@Insert("insert into rbac.employee (name, password, email, age) VALUES (#{name}, #{password}, #{email}, #{age})")
    Long save(Employee employee);

    /**
     * 总数
     * @return
     */
    @Select("select count(*) from rbac.employee")
    int count();

    @Select("select * from rbac.employee where name = #{name}")
    Employee select(String name);

    @Update("update employee set admin = #{just} where id = #{id}")
    void admin(@Param("id")Long id, @Param("just") Boolean just);
}
